Skip to content

Fix #1317: fix: /add/message和/search/memory接口端点被移除了,导致cloud插件不可用#1973

Open
Memtensor-AI wants to merge 1 commit into
dev-20260624-v2.0.22from
bugfix/autodev-1317
Open

Fix #1317: fix: /add/message和/search/memory接口端点被移除了,导致cloud插件不可用#1973
Memtensor-AI wants to merge 1 commit into
dev-20260624-v2.0.22from
bugfix/autodev-1317

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Restores the /add/message, /search/memory, and /get/memory HTTP endpoints that the MemOS Cloud OpenClaw plugin, the openwork desktop integration, and the Python MemOSClient SDK have always called. After the API consolidation in PR #1344, the server only exposed /product/search and /product/add, so every plugin call returned 404 (issue #1317). The fix adds a thin compatibility router (src/memos/api/routers/cloud_compat_router.py) that registers the three cloud-shape paths at the FastAPI app root, translates the cloud plugin's snake_case payload (with both snake_case and legacy camelCase async_mode aliases) into the internal APISearchRequest / APIADDRequest / GetMemoryRequest models, and delegates to the existing AddHandler / SearchHandler / memory_handler -- no internal handler logic is duplicated. The compat router is wired into both server_api.py and server_api_ext.py. Verification: 11 new tests in tests/api/test_cloud_compat_router.py cover endpoint registration, payload field mapping, validation errors, and the async_mode bool/literal conversion; all pass. The targeted regression suite tests/api/test_server_router.py (15 cases) still passes, confirming the /product/* contract is unchanged. ruff check + ruff format clean on all changed files. 4 pre-existing failures in tests/api/test_mcp_serve.py (missing pytest-asyncio in sandbox) confirmed unrelated via git stash baseline check.

Related Issue (Required): Fixes #1317

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Automated tests are pending.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.

Reviewer Checklist

…pat endpoints (#1317)

The MemOS Cloud OpenClaw plugin, the openwork desktop integration, and
the Python MemOSClient SDK all POST to `/add/message`, `/search/memory`,
and `/get/memory`. The server side only exposed `/product/search` and
`/product/add` after the API consolidation in #1344, so every plugin
call returned 404.

Add a thin compatibility router under
`src/memos/api/routers/cloud_compat_router.py` that:

- Registers the three cloud-shape paths at the FastAPI app root.
- Translates cloud-plugin snake_case payloads (with both snake_case and
  legacy camelCase async_mode aliases) into the internal
  APISearchRequest / APIADDRequest / GetMemoryRequest models.
- Folds plugin metadata (source / app_id / agent_id / allow_public)
  into APIADDRequest.info instead of dropping it.
- Delegates to the existing AddHandler, SearchHandler, and
  memory_handler -- no handler logic is duplicated.

Wire the compat router into both `server_api.py` and
`server_api_ext.py`. Add `tests/api/test_cloud_compat_router.py` (11
new cases) covering endpoint registration, payload mapping, validation
errors, and the async_mode bool/literal conversion. Targeted regression
suite `tests/api/test_server_router.py` still passes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants